package gamagora.game.map
{
	import gamagora.game.animations.OSAnimation;
	
	import org.flixel.FlxSprite;
	
	public class OSBackground extends FlxSprite
	{
		protected var _osAnimations:Vector.<OSAnimation>;
		protected var _nbOsAnimations:uint;
		
		public function OSBackground(SimpleGraphic:Class=null)
		{
			super(0, 0, SimpleGraphic);
			_osAnimations = new Vector.<OSAnimation>();
			
			create(_osAnimations);
			
			_nbOsAnimations = _osAnimations.length;
		}
		
		protected function create(animations:Vector.<OSAnimation>):void
		{
			
		}
		
		public override function update():void
		{
			super.update();
			for(var i:uint=0;i<_nbOsAnimations;i++)
			{
				_osAnimations[i].update();
				_osAnimations[i].postUpdate();
			}
		}
		
		public override function draw():void
		{
			super.draw();
			for(var i:uint=0;i<_nbOsAnimations;i++)
			{
				var osX:Number = _osAnimations[i].x;
				_osAnimations[i].x += x;
				_osAnimations[i].draw();
				_osAnimations[i].x = osX;
			}
		}
		
		public override function destroy():void
		{
			super.destroy();
			for(var i:uint=0;i<_nbOsAnimations;i++)
			{
				_osAnimations[i].destroy();
			}
		}
	}
}
